package org.eclipse.php.internal.console.ui.view;

import java.util.ArrayList;
import java.util.List;
import java.util.Observable;

public class HistoryListModel extends Observable {
	private List historyList;
	private boolean cleared;
	
	public HistoryListModel() {
		historyList = new ArrayList();
	}
	
	public List getHistoryList() {
		return historyList;
	}
	
	public void setHistoryList(List historyList) {
		this.historyList = historyList;
		setChanged();
		notifyObservers(this);
	}
	
	public void clearHistoryListModel() {
		historyList.clear();
		cleared = true;
		setChanged();
		notifyObservers(this);
	}
	
	public void addHistoryElement(HistoryElement element) {
		historyList.add(element.toArray());
		setChanged();
		notifyObservers(this);
	}
	
	public Object[] toArray() {
		int size = historyList.size();
		Object[] obj = new Object[size];
		return historyList.toArray(obj);
	}
	
	public boolean isCleared() {
		return cleared;
	}
	
	public void setCleared(boolean b) {
		cleared = b;
	}
}
